<!--
 *@开发者: 刘翔
 *@创建时间: 2024-04-26 10:33:30
 *@描述:表格
!-->
<template>
  <div
    class="form-list"
    :style="{
      '--borderColor': borderColor,
    }"
  >
    <div class="form-list-title-list" :style="{ height: topHeightValue, fontSize: fontSizeTile }">
      <div
        class="form-list-title"
        v-for="(item, index) in formParameter"
        :key="index"
        :style="{
          width: item.width,
          background: topTitleBackgroundColor,
          color: topTitleFontColor,
        }"
      >
        {{ item.title }}
      </div>
    </div>
    <div class="form-list-content-list" :style="{ height: bottomHeightValue, fontSize: fontSizeContent }">
      <div
        class="form-list-content-list-item"
        :style="{
          background: index % 2 == 0 ? lineOneColor : lineTwoColor,
        }"
        v-for="(item, index) in data_list"
        :key="index"
      >
        <div
          v-for="(item1, index1) in formParameter"
          :key="index1"
          class="form-list-item"
          :style="{
            width: item1.width,
            color: item[item1.highlightValue] ? '#ff1c0f' : '#000',
            fontSize: item1.fontSizeContent,
          }"
        >
          <span v-if="item1.sliceShow && item[item1.title] != null">{{ Math.floor(item[item1.title] * 100) / 100 }}</span>
          <span v-else>{{ item[item1.title] }}</span>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  // 组件名称
  name: 'formList',
  // 组件参数 接收来自父组件的数据
  props: {
    //标题文字颜色
    topTitleFontColor: {
      type: String,
      default: '#fff',
    },
    //标题背景颜色
    topTitleBackgroundColor: {
      type: String,
      default: '#4874cb',
    },
    //边框颜色
    borderColor: {
      type: String,
      default: '#000',
    },
    //单行颜色
    lineOneColor: {
      type: String,
      default: '#fff',
    },
    //双行颜色
    lineTwoColor: {
      type: String,
      default: '#edeced',
    },
    topHeightValue: {
      type: [String, Number],
      default: '5%',
    },
    bottomHeightValue: {
      type: [String, Number],
      default: '95%',
    },
    fontSizeTile: {
      type: [String, Number],
      default: '1.3rem',
    },
    fontSizeContent: {
      type: [String, Number],
      default: '1.3rem',
    },
    formParameter: {
      type: Array,
      default: () => {
        return [];
      },
    },
    data_list: {
      type: Array,
      default: () => {
        return [];
      },
    },
  },
  // 局部注册的组件
  components: {},
  // 组件状态值
  data() {
    return {};
  },
  // 计算属性
  computed: {},
  // 侦听器
  watch: {},
  // 组件方法
  methods: {},
  created() {},
  mounted() {},
};
</script>

<style lang="less" scoped>
.form-list {
  --borderColor: #000;
  width: 100%;
  height: 100%;
  border: 1px solid var(--borderColor);
  font-size: 1.2rem;
  .form-list-title-list {
    display: flex;
    height: 5%;
    .form-list-title {
      padding: 0 10px;
      display: flex;
      align-items: center;
      justify-content: center;
      height: 100%;
      background: #9accfe;
      border: 1px solid var(--borderColor);
    }
  }
  .form-list-content-list {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 95%;
    .form-list-content-list-item {
      display: flex;
      width: 100%;
      flex: 1;
      .form-list-item {
        padding: 0 1%;
        display: flex;
        align-items: center;
        justify-content: center;
        height: 100%;
        border: 1px solid var(--borderColor);
        box-sizing: border-box;
      }
    }
  }
}
</style>
